class Image < ActiveRecord::Base
  file_column :filename, :magick => {:versions => {'thumb' => '100x100>'}}
  has_and_belongs_to_many :templates

  validates_uniqueness_of :title
  validates_presence_of :title, :filename

  acts_as_taggable

  def related_images
    Image.find_tagged_with(self.tag_list) - [self]
  end

  # active_scaffold callbacks: authorized_for_crud
  def authorized_for_create?
    true
  end

  def authorized_for_read?
    true
  end

  def authorized_for_update?
    true
  end

  def authorized_for_destroy?
    true
  end

  # human names
  ModelName = "图片"
  ColumnNames ={
    :title => "名称",
    :filename => "文件",
    :templates => "用于模版",
    :tag_list => "标签",
    :related_images => "相关图片"
  }
end
